# -*- coding: utf-8 -*-
# @Time : 2021/12/30 10:22
# @Author : Limusen
# @File : demo_iframe_09

import time
from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://sahitest.com/demo/jsPopup.htm")
driver.implicitly_wait(5)
driver.find_element_by_xpath('//button').click()

# 　处理alert弹框
time.sleep(2)
driver.switch_to.alert.accept() # 确认按钮
time.sleep(2)
# 取消按钮
driver.switch_to.alert.dismiss()
time.sleep(2)
driver.switch_to.alert.send_keys("测试一下输入")
time.sleep(2)
driver.switch_to.alert.dismiss()
#备注：send_keys这个方法在chromedriver中输入后不会显示。
